<?php
/*
 * program:	均源
 * author:	雨中漫步 & 上善若水 & qhxin
 * email:	qhxin@qhxin.com
 * date:	2014/11/11
 * description:	又是一年双十一，不能剁手，就写点东西吧~~~~~~
 */

defined('IN_SCHOOL') or die();

/*{TranslateTagBegin}*/
class control_search extends base_control{

	//hook ctr_search_start.php
	public function __construct() {
	
		//hook ctr_search_init_before.php
		parent::__construct();
		
		//hook ctr_search_init_end.php
	}
	
	public function do_index() {
		$s = core::gpc('s','R');
		$s2 = base64_decode(core::gpc('s2','G'));
		if(!empty($s2)) $s = $s2;
		
		//hook ctr_search_index_before.php
		if(!empty($s)) {
			//hook ctr_search_page_before.php
			$pagesize = $limit = max(0, $this->confs['_conf_bbs_pagesize']);
			$page	= html::page('page');
			$count = $this->talks->talks_search_count($s);
			$pages = html::pages('index.php?search-index-s2-'.base64_encode($s).'.htm', $count, $page, $pagesize);
			
			$start = ($page-1)*$pagesize;
			$talks = $this->talks->talks_search_list($s, $start , $limit );
	
			//hook ctr_search_page_end.php
			$this->tpl->assign('pages', $pages);
			$this->tpl->assign('talks', $talks);
		}
		
		//hook ctr_search_index_end.php
		$this->tpl->assign('s', $s);
		$this->tpl->display('search_index.tpl');
	}
	//hook ctr_search_end.php

}
/*{TranslateTagEnd}*/

?>